<div class=" admin-content">
<div class="daohang"></div>
<div class="admin-biaogelist">
	
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on"> 留言管理</ul>
      
      <dl class="am-icon-home" style="float: right;"> 当前位置： <a href="{:U('Index/index')}">首页</a> > <a href="{:U('Msg/index')}">留言管理</a> > 留言列表</dl>
    </div>
    <form class="am-form am-g" id="cont_form">
          <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
            <thead>
              <tr class="am-success">
                <th></th>
                <th class="table-id">ID</th>
                <th class="table-title">联系人</th>
                <th class="table-type">手机</th>
                <th class="table-type">电话</th>
                <th class="table-date am-hide-sm-only">留言日期</th>
                <th width="163px" class="table-set">操作</th>
              </tr>
            </thead>
            <tbody>
            <volist name="data" id="vo">
              <tr>
                <td><input type="checkbox" name="id[]" value="{$vo.id}" /></td>
                <td>{$vo.id}</td>
                <td>{$vo.name}</td>
                <td>{$vo.phone}</td>
                 <td>{$vo.tel}</td>
                <td class="am-hide-sm-only">{:date('Y-m-d H:m:s',$vo['ctime'])}</td>
                <td><div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                      <a href="{:U('info',array('id'=>$vo['id']))}" class="am-btn am-btn-default am-btn-xs am-text-secondary am-round">查看</a>
                      <button type="button" onclick="del({$vo.id})" class="am-btn am-btn-default am-btn-xs am-text-danger am-round">删除</button>
                    </div>
                  </div></td>
              </tr>
              </volist>
            </tbody>
          </table>
          <div class="am-btn-group am-btn-group-xs">
              <input type="checkbox" id="checkall"> 全选
            </div>
          
                 <div class="am-btn-group am-btn-group-xs">
              <button id="alldel" type="button" class="am-btn am-btn-red">批量删除</button>
            </div>
            {$show}
          
          <!-- <ul class="am-pagination am-fr">
                <li class="am-disabled"><a href="#">«</a></li>
                <li class="am-active"><a href="#">1</a></li>
                <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li><a href="#">»</a></li>
              </ul> -->
          
        </form>
 <script type="text/javascript">
   //单个删除
  function del(id){
    if(!confirm('确定要删除吗？')){
      return false;
    }
    $.ajax({
      url : "{:U('del')}",
      data : {'id':id},
      type : 'post',
      dataType : 'json',
      success : function(res){
        if(res.status == 'OK'){
          alert(res.msg);
          location = "__SELF__";
        }
        else if(res.status == 'NO'){
          alert(res.msg);
        }
      }
    });
  }

  //批量删除
  $('#alldel').on('click',function(){
    var Checkbox = false;
    $("input[name='id[]']").each(function() {
      if(this.checked == true) {
        Checkbox = true;
      }
    });
    if(!Checkbox){
      alert('请选择要删除的内容');
      return false;
    }
    if(!confirm('确定要删除选中内容吗？')){
      return false;
    }
    var data = $("#cont_form").serialize()
    $.ajax({
      url : "{:U('alldel')}",
      data : data,
      type : 'post',
      dataType : 'json',
      success : function(res){
        if(res.status == 'OK'){
          alert(res.msg);
          location = "__SELF__";
        }
        else if(res.status == 'NO'){
          alert(res.msg);
        }
      }
    });
  })
  
  //全选
  $("#checkall").click(function() {
    if(this.checked){
      this.checked = true;
      $("input[name='id[]']").each(function() {
        this.checked = true;
      });
    }
    else{
      this.checked = false;
      $("input[name='id[]']").each(function() {
        this.checked = false;
      });
    }
    
  });

 </script>